import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

class Demo3_1_4_5_2 {
    @SuppressWarnings({"Convert2MethodRef", "SimplifyStreamApiCallChains"})
    public static void main(String[] args) {
        List<Person> list = Arrays.asList(
                new Person("张三", 12)
                , new Person("李四", 11)
                , new Person("王五", 12)
                , new Person("赵六", 11)
        ).stream().collect(Collectors.toList());
        System.out.println("--------------- toMapNew 前");
        System.out.println(list);
        System.out.println("--------------- toMapNew 后");
        Map<Integer, Person> map = list.stream().collect(CustomCollectors.toMapNew(k -> k.getAge()));
        System.out.println(map);
    }
}